<?php
include_once("../module/micro_shop/includes/plugin_micro_shop_class.php");

$microShop = new MicroShop();

//保存
if($_POST['act']=='shop_create' && $_POST['member_id']>0){
    $payInfo = array(
        'admin_name'=>"{$_SESSION['ADMIN_USER']}",
        'payment_name'=>"SELF",
        'text'=>"人工操作",
        'behavior'=>"开店"
    );
    
    //检查微店名称是否重复
    if($_POST['shopName']){
        $mid = 0;
        $sql = "select member_id from ".MICROSHOP." where name='{$_POST['shopName']}'";
        $db->query($sql);
        $mid = $db->fetchField('member_id');
        if($mid>0){
            echo "<script>alert('微店名称已存在，请重新输入！');</script>";
            die;
        }
    }
    
    $microShop->create_shop($_POST['member_id'],$_POST,$payInfo);
    
    echo "<script>window.parent.main.location.reload();</script>";
    echo "<script>window.parent.DialogManager.close('shop_create');</script>";
    die;
}

$tpl->display('shop_create.htm');